package com.daryl.jcu_project1_creditscoreform;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class Display_form_personal_details extends Activity {

	private EditText usernametest;
	private RadioGroup typeOfApplicant;
	private RadioGroup existingCustomer;
	private EditText nameTitle;
	private EditText customerNum;
	private EditText customerYearsWithHSBC;
	private EditText customerMonthsWithHSBC;
	private EditText customerSurname;
	private EditText customerGivenName;
	private EditText customerDateOfBirth;
	private EditText customerDLDnumber;
	private EditText customerDLDstate;
	private EditText customerDLDexpDate;
	private EditText typeOfVisa;
	private EditText residentOf;
	private EditText numOfChildren;
	private EditText childrenAge1;
	private EditText childrenAge2;
	private EditText childrenAge3;
	private EditText childrenAge4;
	private EditText childrenAge5;
	private EditText childrenAge6;
	
	private RadioGroup customerGender;
	private RadioGroup customerResident;
	private RadioGroup customerCitizen;
	private RadioGroup customerMartialStatus;
	private RadioGroup customerChildren;
	int x = 0;
	public String mTypeOfApplicant;
	public String mExistingCustomer;
	public String mCustomerNumber;
	public String mTimeWithHSBCYears;
	public String mTimeWithHSBCMonths;
	public String vTypeOfApplicant;

	public String vCustomerNumber;
	public String vTimeWithHSBCYears;
	public String vTimeWithHSBCMonths;
	public String vSurname;
	public String vNameTitle;
	public String vResidentOf;
	public String vGivenName;
	public String vGender;
	public String vCitizen;
	public String vDateOfBirth;
	public String vResident;
	public String vVisa;
	public String vDLDnumber;
	public String vDLDstate;
	public String vDLDexpDate;
	public String vMartialStatus;
	public String vChildren;
	public String vNumOfChildren;
	public String vChildrenAge1;
	public String vChildrenAge2;
	public String vChildrenAge3;
	public String vChildrenAge4;
	public String vChildrenAge5;
	public String vChildrenAge6;
	
	public static String vExistingCustomer;

	public static int nextpage = 0;
	public static int backpage = 0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_display_form_personal_details);
		// Show the Up button in the action bar.

		getRadioBtnValueApplicantType();
		getRadioBtnExistingCustomer();
		getRadioBtnGender();
		getRadioBtnResident();
		getRadioBtnCitizen();
		getRadioBtnMartialStatus();
		getRadioBtnChildren();

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(
				R.menu.activity_display_form_personal_details, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	public void buttonClickYes(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llCustomerNumber);
		ll1.setVisibility(View.VISIBLE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llTimeWithHSBC);
		ll2.setVisibility(View.VISIBLE);
	}

	public void buttonClickNo(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llCustomerNumber);
		ll1.setVisibility(View.GONE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llTimeWithHSBC);
		ll2.setVisibility(View.GONE);
	}

	public void residentOfAustralia_buttonClickYes(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llTypeOfVisa);
		ll1.setVisibility(View.VISIBLE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llResidentOf);
		ll2.setVisibility(View.GONE);
	}

	public void residentOfAustralia_buttonClickNo(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llTypeOfVisa);
		ll1.setVisibility(View.GONE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llResidentOf);
		ll2.setVisibility(View.VISIBLE);
	}

	public void childrenQuestion_buttonClickYes(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llNumberOfChildren);
		ll1.setVisibility(View.VISIBLE);

		TextView tv1 = (TextView) findViewById(R.id.tvAgeOfChildren);
		tv1.setVisibility(View.VISIBLE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llAgeOfChildren);
		ll2.setVisibility(View.VISIBLE);
	}

	public void childrenQuestion_buttonClickNo(View view) {
		LinearLayout ll1 = (LinearLayout) findViewById(R.id.llNumberOfChildren);
		ll1.setVisibility(View.GONE);

		TextView tv1 = (TextView) findViewById(R.id.tvAgeOfChildren);
		tv1.setVisibility(View.GONE);

		LinearLayout ll2 = (LinearLayout) findViewById(R.id.llAgeOfChildren);
		ll2.setVisibility(View.GONE);
	}

	public void nextPage(View view) {
		variables vb = new variables();
		Intent intent_next = new Intent(this,
				Display_form_personal_details2.class);
		methods md = new methods();
		int retriveValue = 0;
		
		Display_form_personal_details2 dp2 = new Display_form_personal_details2();

		startActivity(intent_next);
		
		
		
		getCustomerPlaceOfResident();
		getCustomerTitle();
		getCustomerNum();
		getCustomerYearsWithHSBC();
		getCustomerMonthsWithHSBC();
		getCustomerSurname();
		getCustomerGivenName();
		getCustomerDLDnumber();
		getCustomerDLDstate();
		getCustomerDLDexpDate();
		getCustomerTypeOfVisa();
		getCustomerDateOfBirth();
		getNumOfChildren();
		getChildrenAge();
		
		System.out.println("data 1 print " + md.retriveSharePreference(this, "vData" , "dTypeOfApplicant"));
		System.out.println("data 2 print " + md.retriveSharePreference(this, "vData" , "dExistingCustomer"));
		System.out.println("data 3 print " + md.retriveSharePreference(this, "vData" , "dCustomerNumber"));
		System.out.println("data 4 print " + md.retriveSharePreference(this, "vData" , "dTimeWithHSBCYears"));
		System.out.println("data 5 print " + md.retriveSharePreference(this, "vData" , "dTimeWithHSBCMonths"));
		System.out.println("data 6 print " + md.retriveSharePreference(this, "vData" , "dNameTitle"));
		System.out.println("data 7 print " + md.retriveSharePreference(this, "vData" , "dSurname"));
		System.out.println("data 8 print " + md.retriveSharePreference(this, "vData" , "dGivenName"));
		System.out.println("data 9 print " + md.retriveSharePreference(this, "vData" , "dGender"));
		System.out.println("data 10 print " + md.retriveSharePreference(this, "vData" , "dCitizen"));
		System.out.println("data 11 print " + md.retriveSharePreference(this, "vData" , "dDateOfBirth"));
		System.out.println("data 12 print " + md.retriveSharePreference(this, "vData" , "dResident"));
		System.out.println("data 13 print " + md.retriveSharePreference(this, "vData" , "dVisa"));
		System.out.println("data 14 print " + md.retriveSharePreference(this, "vData" , "dResidentOf"));
		System.out.println("data 15 print " + md.retriveSharePreference(this, "vData" , "dDLDnumber"));
		System.out.println("data 16 print " + md.retriveSharePreference(this, "vData" , "dDLDstate"));
		System.out.println("data 17 print " + md.retriveSharePreference(this, "vData" , "dDLDexpDate"));
		System.out.println("data 18 print " + md.retriveSharePreference(this, "vData" , "dMartialStatus"));
		System.out.println("data 19 print " + md.retriveSharePreference(this, "vData" , "dChildren"));
		System.out.println("data 20 print " + md.retriveSharePreference(this, "vData" , "dNumOfChildren"));
		System.out.println("data 21 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge1"));
		System.out.println("data 22 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge2"));
		System.out.println("data 23 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge3"));
		System.out.println("data 24 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge4"));
		System.out.println("data 25 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge5"));
		System.out.println("data 26 print " + md.retriveSharePreference(this, "vData" , "dChildrenAge6"));
		/* if (nextpage > 0){
			System.out.println("next 1.1" + nextpage);
			Display_form_personal_details2 dp2 = new Display_form_personal_details2();
			dp2.resume();
		
			System.out.println("next 1.2");
		nextpage++;
		System.out.println("next 1.3");
		
		}
		System.out.println("next page value " + nextpage);
	}

	public void previousPage(View view) {
		Intent intent_previous = new Intent(this, LoginPage.class);
		startActivity(intent_previous);
		*/
		System.out.println("dp1 backpage " + Display_form_personal_details2.backpage);
		if(md.retriveShareIntPreference(this,retriveValue,"previousPage1")>0){ 
		nextpage++;
		System.out.println("next page dp1 " + md.retriveShareIntPreference(this,retriveValue,"previousPage"));
		}
	}

	// get valuse in type of applicant radio grp
	public void getRadioBtnValueApplicantType() {

		// Gets a reference to our radio group
		// rgTypeOfApplicant is the name of our radio group
		typeOfApplicant = (RadioGroup) findViewById(R.id.rgTypeOfApplicant);
		typeOfApplicant.check(R.id.rgTypeOfApplicant);
		typeOfApplicant
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = typeOfApplicant
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton typeOfApplicantBtn = (RadioButton) findViewById(selected);
						vTypeOfApplicant = typeOfApplicantBtn.getText()
								.toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dTypeOfApplicant", vTypeOfApplicant);
					    editor.commit();
					
					}
				});
		
	}

	// get valuse in existing customer radio grp
	public void getRadioBtnExistingCustomer() {
		 
		// Gets a reference to our radio group
		// rgExistingCustomer is the name of our radio group
		existingCustomer = (RadioGroup) findViewById(R.id.rgHSBCCustomer);
		existingCustomer
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						methods md = new methods();
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = existingCustomer
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton existingCustomerBtn = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vExistingCustomer = existingCustomerBtn.getText()
								.toString();
						
						
						
						
						
						
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dExistingCustomer", vExistingCustomer);
					    editor.commit();
					}
					
				});
		
		

	}

	// get customer number
	public void getCustomerNum() {

		methods md = new methods();
		customerNum = (EditText) findViewById(R.id.etCustomerNo);
		vCustomerNumber = customerNum.getText().toString();
		
		try{
		if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("Yes")) {

			md.editorSharePreferences(this,"dCustomerNumber", vCustomerNumber);
			

		} else if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("No")) {
			md.editorSharePreferences(this,"dCustomerNumber", null);
			
		}
		}
		catch (NullPointerException ne)
		{
			System.out.println("null 2");
		}
	}

	// get customer years with HSBC
	public void getCustomerYearsWithHSBC() {
		methods md = new methods();
		variables vb = new variables();
		
		customerYearsWithHSBC = (EditText) findViewById(R.id.etYear);
		vTimeWithHSBCYears = customerYearsWithHSBC.getText().toString();
		
		try{
		if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("Yes")) {

			md.editorSharePreferences(this,"dTimeWithHSBCYears", vTimeWithHSBCYears);
		
			
		} else if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("No")) {
			md.editorSharePreferences(this,"dTimeWithHSBCYears", null);
		
			
		}
		}
		catch (NullPointerException ne){
			System.out.println("null 3");
		}
	}

	// get customer months with HSBC
	public void getCustomerMonthsWithHSBC() {
		variables vb = new variables();
		methods md = new methods();
		
		customerMonthsWithHSBC = (EditText) findViewById(R.id.etMonth);
		vTimeWithHSBCMonths = customerMonthsWithHSBC.getText().toString();
		
		try{
		if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("Yes")) {

			md.editorSharePreferences(this,"dTimeWithHSBCMonths", vTimeWithHSBCMonths);
			
			
			
		} else if (md.retriveSharePreference(this, mExistingCustomer, "dExistingCustomer").equals("No")) {
			md.editorSharePreferences(this,"dTimeWithHSBCMonths", null);
			
			
		}
		}
		catch (NullPointerException ne){
			System.out.println("null 5");
		}
	}

	// get customer title
	public void getCustomerTitle() {
		variables vb = new variables();
		methods md = new methods();
		nameTitle = (EditText) findViewById(R.id.etNameTitle);
		vNameTitle = nameTitle.getText().toString();
		
		md.editorSharePreferences(this, "dNameTitle", vNameTitle);
	}

	// get customer surname
	public void getCustomerSurname() {
		variables vb = new variables();
		methods md = new methods();
		customerSurname = (EditText) findViewById(R.id.etSurname);
		vSurname = customerSurname.getText().toString();
		
		md.editorSharePreferences(this, "dSurname", vSurname);
	}

	// get customer given name
	public void getCustomerGivenName() {
		variables vb = new variables();
		methods md = new methods();
		customerGivenName = (EditText) findViewById(R.id.etGivenName);
		vGivenName = customerGivenName.getText().toString();
		
		md.editorSharePreferences(this, "dGivenName", vGivenName);
	}

	// get valuse in customer gender radio grp
	public void getRadioBtnGender() {

		// Gets a reference to our radio group
		// rgGenderis the name of our radio group
		customerGender = (RadioGroup) findViewById(R.id.rgGender);
		customerGender
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = customerGender.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton customerGender = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vGender = customerGender.getText().toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dGender", vGender);
					    editor.commit();
					}
				});
	}

	// get valuse in customer citizen radio grp
	public void getRadioBtnCitizen() {

		// Gets a reference to our radio group
		// rgCitizen is the name of our radio group
		customerCitizen = (RadioGroup) findViewById(R.id.rgAustralian);
		customerCitizen
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = customerCitizen
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton customerCitizen = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vCitizen = customerCitizen.getText().toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dCitizen", vCitizen);
					    editor.commit();
						
					}
				});
	}

	// get customer date of birth
	public void getCustomerDateOfBirth() {
		variables vb = new variables();
		methods md = new methods();
		customerDateOfBirth = (EditText) findViewById(R.id.etDOB);
		vDateOfBirth = customerDateOfBirth.getText().toString();
		
		md.editorSharePreferences(this, "dDateOfBirth", vDateOfBirth);
	}

	// get valuse in customer resident radio grp
	public void getRadioBtnResident() {

		// Gets a reference to our radio group
		// rgResidentis the name of our radio group
		customerResident = (RadioGroup) findViewById(R.id.rgResidentOfAustralia);
		customerResident
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = customerResident
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton customerResident = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vResident = customerResident.getText().toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dResident", vResident);
					    editor.commit();
					}
				});
	}

	// get customer type of visa
	public void getCustomerTypeOfVisa() {
		variables vb = new variables();
		methods md = new methods();
		typeOfVisa = (EditText) findViewById(R.id.etTypeOfVisa);
		vVisa = typeOfVisa.getText().toString();
		
		try{
		if( md.retriveSharePreference(this,"vResident", "dResident").equals("Yes")){
			
			md.editorSharePreferences(this,"dResidentOf",null);
			md.editorSharePreferences(this,"dVisa", vVisa);
		}
		else if( md.retriveSharePreference(this,"vResident", "dResident").equals("No")){
		
			md.editorSharePreferences(this,"dResidentOf",vResident);
			md.editorSharePreferences(this,"dVisa", null);
		}
		}
		
		catch (NullPointerException ne){
			System.out.println("null 6");
		}
	}

	// get customer place of resident
	public void getCustomerPlaceOfResident() {
		variables vb = new variables();
		methods md= new methods();
		residentOf = (EditText) findViewById(R.id.etResidentOf);
		vResidentOf = residentOf.getText().toString();
		
		try{
		if( md.retriveSharePreference(this,"vResident", "dResident").equals("Yes")){
		
			md.editorSharePreferences(this,"dResidentOf",null);
			md.editorSharePreferences(this,"dVisa", "vResidentOf");
		}
		else if( md.retriveSharePreference(this,"vResident", "dResident").equals("No")){
		
			md.editorSharePreferences(this,"dResidentOf","vResidentOf");
			md.editorSharePreferences(this,"dVisa", null);
		}
		}
		catch(NullPointerException ne){
			System.out.println("null error");
		}
		
				
	}

	// get customer driving licence number
	public void getCustomerDLDnumber() {
		variables vb = new variables();
		methods md = new methods();
		customerDLDnumber = (EditText) findViewById(R.id.etDriverLicenceNo);
		vDLDnumber = customerDLDnumber.getText().toString();
		
		md.editorSharePreferences(this, "dDLDnumber", vDLDnumber);
	}

	// get customer driving licence state
	public void getCustomerDLDstate() {
		variables vb = new variables();
		methods md = new methods();
		customerDLDstate = (EditText) findViewById(R.id.etDriverLicenceState);
		vDLDstate = customerDLDstate.getText().toString();
		
		md.editorSharePreferences(this, "dDLDstate", vDLDstate );
	}

	// get customer driving licence expire date
	public void getCustomerDLDexpDate() {
		variables vb = new variables();
		methods md = new methods();
		customerDLDexpDate = (EditText) findViewById(R.id.etDriverLicenceExpiryDt);
		vDLDexpDate = customerDLDexpDate.getText().toString();
		
		md.editorSharePreferences(this, "dDLDexpDate", vDLDexpDate);
	}

	// get valuse in customer martial status
	public void getRadioBtnMartialStatus() {

		// Gets a reference to our radio group
		// rgMartialStatus is the name of our radio group
		customerMartialStatus = (RadioGroup) findViewById(R.id.rgMartialStatus);
		customerMartialStatus
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = customerMartialStatus
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton customerMartialStatus = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vMartialStatus = customerMartialStatus.getText()
								.toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dMartialStatus", vMartialStatus);
					    editor.commit();
						
					}
				});
	}

	// get valuse in customer martial status
	public void getRadioBtnChildren() {

		// Gets a reference to our radio group
		// rgChildren is the name of our radio group
		customerChildren = (RadioGroup) findViewById(R.id.rgChildrenQuestion);
		customerChildren
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(RadioGroup group, int checkedId) {
						variables vb = new variables();
						// Returns an integer which represents the selected
						// radio button's ID
						int selected = customerChildren
								.getCheckedRadioButtonId();

						// Gets a reference to our "selected" radio button
						RadioButton customerChildren = (RadioButton) findViewById(selected);
						// bring the selected button to variable class

						vChildren = customerChildren.getText().toString();
						
						SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					    SharedPreferences.Editor editor = preferences.edit();
					    editor.putString("dChildren", vChildren);
					    editor.commit();
					}
				});
		
	}
	
	// get customer Number of children
			public void getNumOfChildren() {
				variables vb = new variables();
				methods md = new methods();
				numOfChildren = (EditText) findViewById(R.id.etNoOfChildren);
				vNumOfChildren = numOfChildren.getText().toString();
				
				try{
				if(md.retriveSharePreference(this, "vChildren", "dChildren").equals("Yes")){
					System.out.println("CHILDREN YES");
				md.editorSharePreferences(this, "dNumOfChildren", vNumOfChildren);
				}
				else {
					System.out.println("CHILDREN NO");
					md.editorSharePreferences(this, "dNumOfChildren", null);
				}
				}
				catch (NullPointerException ne){
					System.out.println("null 8");
				}
			}
			
			// get customer Number of children
						public void getChildrenAge() {
							variables vb = new variables();
							methods md = new methods();
							childrenAge1 = (EditText) findViewById(R.id.etAgeOf1stChildren);
							vChildrenAge1 = childrenAge1.getText().toString();
							childrenAge2 = (EditText) findViewById(R.id.etAgeOf2ndChildren);
							vChildrenAge2 = childrenAge2.getText().toString();
							childrenAge3 = (EditText) findViewById(R.id.etAgeOf3rdChildren);
							vChildrenAge3 = childrenAge3.getText().toString();
							childrenAge4 = (EditText) findViewById(R.id.etAgeOf4thChildren);
							vChildrenAge4 = childrenAge4.getText().toString();
							childrenAge5 = (EditText) findViewById(R.id.etAgeOf5thChildren);
							vChildrenAge5 = childrenAge5.getText().toString();
							childrenAge6 = (EditText) findViewById(R.id.etAgeOf6thChildren);
							vChildrenAge6 = childrenAge6.getText().toString();
							
							try{
							if(md.retriveSharePreference(this, "vChildren", "dChildren").equals("Yes")){
							md.editorSharePreferences(this, "dChildrenAge1", vChildrenAge1);
							md.editorSharePreferences(this, "dChildrenAge2", vChildrenAge2);
							md.editorSharePreferences(this, "dChildrenAge3", vChildrenAge3);
							md.editorSharePreferences(this, "dChildrenAge4", vChildrenAge4);
							md.editorSharePreferences(this, "dChildrenAge5", vChildrenAge5);
							md.editorSharePreferences(this, "dChildrenAge6", vChildrenAge6);
							}
							else {
								md.editorSharePreferences(this, "dChildrenAge1", null);
								md.editorSharePreferences(this, "dChildrenAge2", null);
								md.editorSharePreferences(this, "dChildrenAge3", null);
								md.editorSharePreferences(this, "dChildrenAge4", null);
								md.editorSharePreferences(this, "dChildrenAge5", null);
								md.editorSharePreferences(this, "dChildrenAge6", null);
							}
							}
							catch(NullPointerException ne){
								System.out.println("null 9");
							}
						}
}
